﻿using SBlogCore.Common.DatabaseAccessor;
using SBlogCore.Common.Snowflake;
using SBlogCore.IServices;
using SBlogCore.SysUserManager.Entitys;

namespace SBlogCore.Services
{
    public class SysUserInfoService: ISysUserInfoService
    {
        private GlobalDbContext _dbContext;

        public SysUserInfoService(GlobalDbContext dbContext)
        {
            this._dbContext = dbContext;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task<int> SaveUserinfo(SysUserInfo info)
        { 
            if (info.Id == 0)
            {
                info.Id = IDGenerator.NextId();
            }
            await _dbContext.AddAsync(info);
            return await _dbContext.SaveChangesAsync();
        }
    }
}
